/*
 * @Author: 郝奔 1425466221@qq.com
 * @Date: 2024-11-29 10:20:27
 * @LastEditors: 刘晓伟 1748805421@qq.com
 * @LastEditTime: 2025-02-07 15:56:46
 * @FilePath: /HG-dqbasic_open_platform/src/framework/api/auth/index.ts
 * @Description: 
 * Copyright (c) 2024-present HBIS Digital Technology Co.,Ltd. All rights reserved. 
 */
import { default as request, cloud } from '@/framework/utils/request';
import { LoginData, VerifyCode, TokenResult } from './types';
import { ResultData } from '../common';

/**
 *
 * @param data {LoginForm}
 * @returns
 */
export function loginApi(data: LoginData | string): Promise<ResultData<string & TokenResult>> {
  return request({
    url: 'auth/sso/workbench/loginApi',//'/auth/loginApi',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  });
}

/**
 * 注销
 */
export function logoutApi(): Promise<ResultData<null>> {
  return request({
    url: cloud.businessBasic + '/auth/logout',
    method: 'post',
    data: { loginPlatformDomain: window.location.host }
  });
}

/**
 * 获取图片验证码
 */
export function getCaptcha(): Promise<ResultData<VerifyCode>> {
  return request({
    url: '/captcha?t=' + new Date().getTime().toString(),
    method: 'get'
  });
}
/**
 * @description: 是否鉴权
 * @return {*}
 */
export function isAuth(): Promise<ResultData<null>> {
  return request({
    url: '/integratedPlatform/health',
    method: 'get'
  });
}
